class ThreadDemo extends Thread {
	public ThreadDemo(String threadName){
		super(threadName);
	}
	public synchronized void method()
	{
		System.out.println("THREAD NAME: " +Thread.currentThread().getName());
		try{
			Thread.sleep(5000);
		} catch (InterruptedException e){
			e.printStackTrace();
		}
	}
	public void run() {
		method();
	}
}
public class SampleThread {
	public static void main(String[] args){
		ThreadDemo one = new ThreadDemo("one");
		ThreadDemo two = new ThreadDemo("two");
		one.start();
		two.start();
	}

}
